<?php
// P. Couchet 01/12/2011

session_start();
set_time_limit (0);
ini_set('memory_limit', '512M');

// Fichier de configuration en fonction du serveur
include('../config/config.php');

$dsn='mysql:host='.$host.';port='.$port.';dbname='.$dbname;

// Haut de page
include('../templates/'.$template.'/up.php');
// Connexion, création de $a, inclusion de model.php
include('../action/statusAction.php');

// Default Tab
// Onglet par défaut, le premier de la liste menu
if (empty($_GET) and empty($_POST)){
	$defaultMenu = array_keys($menu);
	$defaultMenu = $defaultMenu[0];
	$_GET[$defaultMenu]=true;
}

// Update of an item
if(isset($_GET['id']) and isset($_GET['saveid']) and isset($_SESSION['login'])){
	$result = $a->updateItem($dbname, $from, $fieldTable, $_GET['id'], $_POST);
	if($result==true) {
		echo '<div style="color:red;padding:1em;">Notice '.$_GET['id'].' sauvegardée : ';
		echo '<span style="color:#333333;">'.$_POST['title'].'; '.$_POST['title_a'].'</span></div>';
	}
	else echo 'Problème dans la requète de modification';
}

// Home About
if(isset($_GET['p'])) include('../templates/'.$template.'/pInfo.php');
// Display all
if(isset($_GET['t'])){
	include('../action/tAction.php');
	include('../templates/'.$template.'/tForm.php');
	if(isset($itemNumber) and $itemNumber > 0) include('../templates/'.$template.'/results.php');
}
// Simple search
if(isset($_GET['s'])){
	if(!empty($_GET['s'])) include('../action/sAction.php');
	include('../templates/'.$template.'/sForm.php');
	if(isset($itemNumber) and $itemNumber > 0) include('../templates/'.$template.'/results.php');
}
// Advanced search
if(isset($_GET['a'])){
	include('../action/aAction.php');
	include('../templates/'.$template.'/aForm.php');
	if(isset($itemNumber) and $itemNumber > 0) include('../templates/'.$template.'/results.php');
}
// Parcourir
if(isset($_GET['x'])){
	// Géolocalisation
	if(isset($_GET['l'])) include('../templates/'.$template.'/lInfo.php');
	// Classement
	elseif (isset($_GET['d'])) include('../templates/'.$template.'/dInfo.php');
	// Temporel par défaut
	else {
		include('../templates/'.$template.'/xInfo.php');
	}
}
// Ressources +
if(isset($_GET['w'])){
	// Bibliographie
	if(isset($_GET['f'])) include('../templates/'.$template.'/fInfo.php');
	// Sites et blogs
	elseif(isset($_GET['g'])) include('../templates/'.$template.'/gInfo.php');
	// Homonymie
	elseif(isset($_GET['i'])) include('../templates/'.$template.'/iInfo.php');
	// A propos
	elseif(isset($_GET['b'])) include('../templates/'.$template.'/bInfo.php');
	// About
	elseif(isset($_GET['j'])) include('../templates/'.$template.'/jInfo.php');
	// Multimédia
	elseif(isset($_GET['u'])) include('../templates/'.$template.'/uInfo.php');
	// Default : Publications
	else {
	// Publications
	//if(isset($_GET['v'])) {
		// ELEMENTS D'HISTOIRE
		if(isset($_GET['pub1'])) include('../templates/'.$template.'/pub1Info.php');
		// Articles
		elseif(isset($_GET['pub2'])) include('../templates/'.$template.'/pub2Info.php');
		// Default : ELEMENTS
		else {
			// ELEMENTS D'HISTOIRE
			if(isset($_GET['em1'])) include('../templates/'.$template.'/em1Info.php');
			// Articles
			elseif(isset($_GET['em2'])) include('../templates/'.$template.'/em2Info.php');
			else include('../templates/'.$template.'/em0Info.php');
		}
	//}
	}
}
// Connexion
if(isset($_GET['k'])) include('../templates/'.$template.'/kForm.php');
// Contact
if(isset($_GET['h'])) include('../templates/'.$template.'/hInfo.php');
// Mentions légales
if(isset($_GET['c'])) include('../templates/'.$template.'/cInfo.php');
// Accessibilité
if(isset($_GET['e'])) include('../templates/'.$template.'/eInfo.php');

include('../templates/'.$template.'/down.php');

?>
